package com.xx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Suppliers;
import com.xx.mapper.SuppliersMapper;
import com.xx.service.ISuppliersService;
import com.xx.vo.SuppliersListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SuppliersServiceImpl implements ISuppliersService{
    @Autowired
    SuppliersMapper suppliersMapper;

    @Override
    public Suppliers queryById(Integer supplierId) {
        return suppliersMapper.queryById(supplierId);
    }

    @Override
    public PageInfo<Suppliers> queryByPage(Suppliers suppliers, Integer pageNum) {
        PageHelper.startPage(pageNum,2);
        List<Suppliers> list = suppliersMapper.queryAllByLimit(suppliers,pageNum);
        PageInfo<Suppliers> pageInfo =  new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int insert(Suppliers suppliers) {
        return suppliersMapper.insert(suppliers);
    }

    @Override
    public int update(Suppliers suppliers) {
        return suppliersMapper.update(suppliers);
    }

    @Override
    public int deleteById(Integer supplierId) {
        return suppliersMapper.deleteById(supplierId);
    }

    @Override
    public List<SuppliersListVO> queryAll() {
        return suppliersMapper.queryAll();
    }
}
